package com.xm.xmapp.app;

import android.app.Application;

import com.android.volley.DefaultRetryPolicy;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.xm.xmapp.http.NetWorkData;
import com.xm.xmapp.http.PostData;
import com.xm.xmapp.base.ReqBaseBean;

import cn.jpush.android.api.JPushInterface;

/**
 * Created by LDW on 2017/7/14.
 */
public class MyAppcation extends Application{
    private RequestQueue requestQueue;
    private static MyAppcation instence;
    @Override
    public void onCreate() {
        super.onCreate();
        instence = this;
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
        requestQueue = Volley.newRequestQueue(this);
//        AutoLayoutConifg.getInstance().useDeviceSize();

    }

    public static MyAppcation getMyAppcation(){
        return instence;
    }

    /**
     * 发起请求
     *
     * @param activity
     * @param requestBean
     * @param listener
     * @param
     */
    public void getPostData(Object activity, ReqBaseBean requestBean, NetWorkData listener,
                            int code) {
        PostData request = new PostData(requestBean, code , listener);
        request.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        if (activity != null)
            request.setTag(activity.getClass().getSimpleName());
        requestQueue.add(request);
    }
}
